<?php

class Core_Model_Design_Page_Template extends Dcmp_Model_Entity {

    public function __construct() {
        parent::__construct();
    }

    public function getPositions() {
        return App::getModel('design/collection_page_position')
                ->joinTemplate()
                ->filterByTemplateId($this->getId());
    }

    public function getWebsiteTheme(){
        if(!$this->issetData('website_theme') && $this->issetData('website_theme_id')){
            $this->data['website_theme'] = App::getModel('design/website_theme')->load($this->getWebsiteThemeId());
        }
        return $this->data['website_theme'];
    }

    public function getPageTheme(){
        if(!$this->issetData('page_theme') && $this->issetData('page_theme_id')){
            $this->data['page_theme'] = App::getModel('design/page_theme')->load($this->getPageThemeId());
        }
        return $this->data['page_theme'];
    }

    public function getArea() {
        if (!$this->issetData('area')) {
            $this->data['area'] = App::getModel('global/area')->load($this->getAreaId());
        }
        return $this->data['area'];
    }

    protected function initializeTable($table) {
        $table->setName('{t}design_page_template');
        $table->createColumn('id', 'guid', TRUE);
        $table->createColumn('name', 'string');
        $table->createColumn('skin', 'string');
        $table->createColumn('file_name', 'string');
        $table->createColumn('website_theme_id', 'string');
        $table->createColumn('page_theme_id', 'string');
        $table->createColumn('area_id', 'string');
        $table->createColumn('enabled', 'integer');
    }

}